<?php

interface Product
{
    public function show(): void;
}

class ConcreteProductA implements Product
{
    public function show(): void
    {
        echo "I`m A .\n";
    }
}

// 创建抽象类
abstract class Creator
{
    //抽象工厂方法
    abstract protected function FactoryMethod(): Product;

    // 抽象操作方法
    public function AnOperation(): Product
    {
        return $this->FactoryMethod();
    }
}

// 创建实现类A
class ConcreteCreatorA extends Creator
{
    // 实现操作方法
    protected function FactoryMethod(): Product
    {
        return new ConcreteProductA();
    }
}